import { POST, GET } from '../axios.config.js'

const base = window.config.ip
const taskApi = `${base}/topnet-assess/sa-assess-task`
const configApi = `${base}/topnet-assess/sa-assess-config`
const codeApi = `${base}/topnet-assess/code-public`
const platApi = `${base}/topnet-assess/platform`
const actApi = `${base}/rcdg-activity/act`

const URLS = {
  getYearList: `${base}/topnet-assess/sa-assess-data/getYearList`, // 获取年份列表
  getAssessDataList: `${taskApi}/queryAssessDataList`, // 考核配置数据列表分页查询
  createAssessTask: `${taskApi}/createAssessTask`, // 新建考核任务
  saveAssessData: `${taskApi}/saveAssessData`, // 保存考核任务数据
  delAssessTask: `${taskApi}/delAssessTask`, // 删除考核任务数据
  selectAssessDataDetail: `${taskApi}/selectAssessDataDetail`, // 获取考核任务数据详情
  getAllOrgan: `${configApi}/getAllOrgan`, // 获取所有部门
  getqueryAssessUser: `${configApi}/queryAssessUser`, // 查询考核用户列表
  getAssessUserDetail: `${configApi}/getAssessUserDetail`, // 查询考核用户详细信息
  getlistOrgAndLeader: `${configApi}/listOrgAndLeader`, // 获取参评机构及负责人列表
  queryUiasCodeInfo: `${codeApi}/queryUiasCodeInfo`, // 根据代码类型查询对应的权限代码表
  getBaseConfig: `${platApi}/getBaseConfig`, // 获取平台基础配置
  saveBaseConfig: `${platApi}/saveBaseConfig`, // 保存考核相关配置
  getIsFirstLogin: `${platApi}/isFirstLogin`, // 是否是首次登录
  getIsShowGuide: `${platApi}/isShowGuide`, // 是否展示指引
  subNotShowGuide: `${platApi}/notShowGuide`, // 不再展示指引
  selectActCycleYear: `${actApi}/selectActCycleYear`, // 查询纪实周期年份
  selectActCycleQuarter: `${actApi}/selectActCycleQuarter`, // 查询纪实周期季度
  selectActCycleMonth: `${actApi}/selectActCycleMonth`, // 查询纪实周期月份
  selectActCycleWeek: `${actApi}/selectActCycleWeek`, // 查询纪实周期周数
  selectActList: `${actApi}/selectActList`, // 分页查询活动列表信息
  createActByTypeCycle: `${actApi}/createActByTypeCycle`, // 推动指定类型&周期纪实信息
}

// 获取年份列表
export const getYearList = () => POST(URLS.getYearList, {})

// 考核配置数据列表分页查询
export const getAssessDataList = ({ keywords, status, tenantId, year }, currentPage = 1, pageSize = 10) =>
  POST(URLS.getAssessDataList, {
    param: {
      keywords,
      status,
      tenantId: localStorage.pskh_tenantId,
      year,
    },
    currentPage,
    pageSize,
  })

// 新建考核任务
export const createAssessTask = ({ status, tenantId, year, quarter, templateId, assessType = '' }) =>
  POST(URLS.createAssessTask, {
    status,
    tenantId: localStorage.pskh_tenantId,
    year,
    quarter,
    templateId,
    assessType,
  })

// 保存考核任务数据
export const saveAssessData = ({
  status,
  tenantId,
  year,
  quarter,
  templateId,
  assessType,
  extEndTime,
  startTime,
  title,
  id,
}) =>
  POST(URLS.saveAssessData, {
    status,
    tenantId: localStorage.pskh_tenantId,
    year,
    quarter,
    templateId,
    assessType,
    extEndTime,
    startTime,
    title,
    id,
  })

// 删除考核任务数据
export const delAssessTask = id =>
  POST(URLS.delAssessTask, {
    id,
  })

// 获取考核任务数据详情
export const selectAssessDataDetail = id =>
  POST(URLS.selectAssessDataDetail, {
    id,
  })

// 获取所有部门
export const getAllOrgan = () => POST(URLS.getAllOrgan)

// 查询考核用户列表
export const getqueryAssessUser = (
  { busPeriod, isRefresh, keywords, labelCode, orgId, quarter, status, tenantId, type, userId, year },
  currentPage,
  pageSize
) =>
  POST(URLS.getqueryAssessUser, {
    currentPage,
    pageSize,
    param: {
      busPeriod,
      isRefresh,
      keywords,
      labelCode,
      orgId,
      quarter,
      status,
      tenantId: localStorage.pskh_tenantId,
      type,
      userId,
      year,
    },
  })

// 查询考核用户详细信息
export const getAssessUserDetail = id =>
  POST(URLS.getAssessUserDetail, {
    id,
  })

// 获取参评机构及负责人列表
export const getlistOrgAndLeader = id =>
  POST(URLS.getlistOrgAndLeader, {
    id,
  })

// 根据代码类型查询对应的权限代码表
export const queryUiasCodeInfo = ({ occurrenceTime = '', oneParam, tenantId }) =>
  POST(URLS.queryUiasCodeInfo, {
    occurrenceTime,
    oneParam,
    tenantId: localStorage.pskh_tenantId,
  })

// 获取平台基础配置
export const getBaseConfig = id =>
  POST(URLS.getBaseConfig, {
    id: localStorage.pskh_tenantId,
  })

// 根据代码类型查询对应的权限代码表
export const saveBaseConfig = ({ systemIcon, systemBackground, platformName, tenantId }) =>
  POST(URLS.saveBaseConfig, {
    systemIcon,
    systemBackground,
    platformName,
    tenantId: localStorage.pskh_tenantId,
  })

// 是否是首次登录
export const getIsFirstLogin = () => POST(URLS.getIsFirstLogin, {})

// 是否展示指引
export const getIsShowGuide = () => POST(URLS.getIsShowGuide, {})

// 不再展示指引
export const subNotShowGuide = () => POST(URLS.subNotShowGuide, {})

// 查询纪实周期年份
export const selectActCycleYear = () =>
  POST(URLS.selectActCycleYear, {
    optionUserId: localStorage.pskh_userId,
    tenantId: localStorage.pskh_tenantId,
  })

// 查询纪实周期季度
export const selectActCycleQuarter = ({ actType, actYear }) =>
  POST(URLS.selectActCycleQuarter, {
    optionUserId: localStorage.pskh_userId,
    tenantId: localStorage.pskh_tenantId,
    actType,
    actYear,
  })

// 查询纪实周期月份
export const selectActCycleMonth = ({ actType, actYear }) =>
  POST(URLS.selectActCycleMonth, {
    optionUserId: localStorage.pskh_userId,
    tenantId: localStorage.pskh_tenantId,
    actType,
    actYear,
  })

// 查询纪实周期周数
export const selectActCycleWeek = ({ actType, actYear, actMonth }) =>
  POST(URLS.selectActCycleWeek, {
    optionUserId: localStorage.pskh_userId,
    tenantId: localStorage.pskh_tenantId,
    actType,
    actYear,
    actMonth,
  })

// 分页查询活动列表信息
export const selectActList = ({ current, size }) =>
  GET(URLS.selectActList, {
    current,
    size,
    optionUserId: localStorage.pskh_userId,
    tenantId: localStorage.pskh_tenantId,
    type: '',
  })

// 推送指定类型&周期纪实信息
export const createActByTypeCycle = ({ actType, actYear, actQuarter, actMonth, actWeek }) =>
  POST(URLS.createActByTypeCycle, {
    optionUserId: localStorage.pskh_userId,
    tenantId: localStorage.pskh_tenantId,
    actType,
    actYear,
    actQuarter,
    actMonth,
    actWeek,
  })
